#!/bin/sh

#启动的配置dev test product
ehp_profile=dev

# EHP MySQL数据库配置
ehp_mysql_db_url="jdbc:mysql:replication://10.9.2.8:3306,10.9.2.9:3306/dev_ehp?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF8&useSSL=false"
ehp_mysql_db_username=ehp_java
ehp_mysql_db_password=EiHKjChA7n5miwpv
EHP_MYSQL_OPTS="-Dehp_mysql_db_url=$ehp_mysql_db_url -Dehp_mysql_db_username=$ehp_mysql_db_username -Dehp_mysql_db_password=$ehp_mysql_db_password"

# CMS MySQL数据库配置
cms_mysql_db_url="jdbc:mysql:replication://10.9.2.8:3306,10.9.2.9:3306/dev_cms?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF8&useSSL=false"
cms_mysql_db_username=ehp_java
cms_mysql_db_password=EiHKjChA7n5miwpv
CMS_MYSQL_OPTS="-Dcms_mysql_db_url=$cms_mysql_db_url -Dcms_mysql_db_username=$cms_mysql_db_username -Dcms_mysql_db_password=$cms_mysql_db_password"

# DS MySQL数据库配置
ds_mysql_db_url="jdbc:mysql:replication://10.9.2.8:3306,10.9.2.9:3306/dev_ds?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF8&useSSL=false"
ds_mysql_db_username=ehp_java
ds_mysql_db_password=EiHKjChA7n5miwpv
DS_MYSQL_OPTS="-Dds_mysql_db_url=$ds_mysql_db_url -Dds_mysql_db_username=$ds_mysql_db_username -Dds_mysql_db_password=$ds_mysql_db_password"

# BASIC MySQL数据库配置
basic_mysql_db_url="jdbc:mysql:replication://10.9.2.8:3306,10.9.2.9:3306/dev_ds?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF8&useSSL=false"
basic_mysql_db_username=ehp_java
basic_mysql_db_password=EiHKjChA7n5miwpv
BASIC_MYSQL_OPTS="-Dbasic_mysql_db_url=$basic_mysql_db_url -Dbasic_mysql_db_username=$basic_mysql_db_username -Dbasic_mysql_db_password=$basic_mysql_db_password"
MYSQL_OPTS="$EHP_MYSQL_OPTS $CMS_MYSQL_OPTS $DS_MYSQL_OPTS $BASIC_MYSQL_OPTS"

# Redis 配置
ehp_redis_host=10.9.2.94
ehp_redis_port=6379
ehp_redis_password=Z6Jte9NzNfHBfJlB
ehp_redis_database=1
REDIS_OPTS="-Dehp_redis_host=$ehp_redis_host  -Dehp_redis_port=$ehp_redis_port -Dehp_redis_password=$ehp_redis_password -Dehp_redis_database=$ehp_redis_database"

# mongo 配置
ehp_mongodb_uri=mongodb://ehp_java:8synXDDkJhOftART@10.9.2.16:27017,10.9.2.32:27017,10.9.2.49:27017/dev_ehp
MONGODB_OPTS="-Dehp_mongodb_uri=$ehp_mongodb_uri"

#MQTT 配置
mqtt_servers=tcp://emqtt.dev.naiterui.com:61615,tcp://emqtt.dev.naiterui.com:61616
mqtt_inner_servers=tcp://10.9.2.102:61613,tcp://10.9.2.110:61613
MQTT_OPTS="-Dmqtt_servers=$mqtt_servers -Dmqtt_inner_servers=$mqtt_inner_servers"

#ES 配置
es_nodes="10.9.2.103:9300;10.9.2.104:9300;10.9.2.105:9300"
es_replicas=2
ES_OPTS="-Des_nodes=$es_nodes -Des_replicas=$es_replicas"

#服务网关
gateway_meta=http://dev.naiterui.com
#图片域名
imghost_meta=http://img.dev.naiterui.com
#患者H5
patientH5_meta=http://patient.dev.naiterui.com
#医生H5
doctorH5_meta=http://doctorapp.dev.naiterui.com
META_SERVERS_OPTS="-Dgateway_meta=$gateway_meta -Dimghost_meta=$imghost_meta -DpatientH5_meta=$patientH5_meta -DdoctorH5_meta=$doctorH5_meta"

#日志目录
LOG_PATH="/Users/wangzehao/work/ehp-server-combine/target/"

#是否容器启动，如果是容器启动，这里必须要设置成true，本地开发调试需要设置成false，用来走域名调用，容器能使用service name调用
enbale_container=true

#k8s中service前缀，这里使用约定，$service_prefix + 应用服务名 is_container=true 才生效
service_prefix=service-

CONTAINER_OPTS="-Denbale_container=$enbale_container -Dservice_prefix=$service_prefix"

echo "==== starting to build app ===="

mvn clean install -U -Dmaven.test.skip=true -P $ehp_profile -Dlog_path=$LOG_PATH $MYSQL_OPTS $REDIS_OPTS $MONGODB_OPTS $MQTT_OPTS $ES_OPTS $META_SERVERS_OPTS $CONTAINER_OPTS

echo "==== building app finished ===="
